package com.woniu.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.woniu.entity.PageResult;
import com.woniu.entity.dto.LogSearchDTO;
import com.woniu.mapper.LogMapper;
import com.woniu.pojo.Log;
import com.woniu.service.ILogService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 日志业务处理对象
 * @author tarnett
 */
@Service
public class ILogServiceImpl implements ILogService {
    @Resource
    private LogMapper logMapper;

    @Override
    public PageResult<Log> listSearch(LogSearchDTO logSearchDTO) {
        PageHelper.startPage(logSearchDTO.getCurrentPage(), logSearchDTO.getPageSize());
        Page<Log> page = logMapper.listSearch(logSearchDTO);
        PageResult<Log> pageResult = new PageResult<>();
        pageResult.setTotal(page.getTotal());
        pageResult.setData(page.getResult());
        return pageResult;
    }

    @Override
    public void save(Log log) {
        logMapper.save(log);
    }

    @Override
    public Integer deleteByIds(Long[] ids) {
        return logMapper.deleteByIds(ids);
    }

    @Override
    public Log getById(Long id) {
        return logMapper.getById(id);
    }
}
